<?php
require_once 'connexion (2).php';
//require_once 'fonction.php';
require_once 'telech.php';
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
        <link rel="stylesheet" href="feuilledestyle.css">
        <link rel="stylesheet" href="menuHead/jquery.cleditor.css">
        <link href="menu2/styles.css" rel="stylesheet" type="text/css">
        <link rel="stylesheet" type="text/css" href="edittexte/CLEditor1_3_0/jquery.cleditor.css" />
 <!--<script type="text/javascript" src="h ttp://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 --><script type="text/javascript" src="edittexte/CLEditor1_3_0/jquery.cleditor.min.js"></script>
   
 <script type="text/javascript">      
$(document).ready(function() {  $("#ajcom").cleditor();  });  
</script>
    </head>
    <body vlink="blue">
        <div id="page">
        <?php include 'header.php';?>
        <div id="cadre">
            <?php include 'menu.php';
            
         /*   if (isset($_SESSION['mail']))
		{
                $ses1=$_SESSION['mail'];
		
                $vco1="select * from personne where MAILPERSONNE ='".$ses1."'";
		$res1=$connexion->query($vco1);//mysql_query($vco1) or die ('erreur dans la requete select :'.mysql_error());
		
		
					
		if($donne =$res1->fetch(PDO::FETCH_ASSOC))
		    { 
			$statut1=$donne['TYPEPERSONNE'];
			//$aut=$donne['autori'];
			
			if ($statut1 == "admin")
			   { */?>
             <FORM style="float:left; margin-top: 20px; background-color: orange; "> <INPUT TYPE="button" VALUE="Retour" onClick="history.back()"> </FORM> 
            <div class="centre">
                <div id="compteR"> </div>
                <br>
                <h3>Les suivi des stages</h3>
                <?php
                 $type=null;
                 if(!(isset($_GET["typep"])))
                {
                    die("Parametre 'id' absent");
                }
                else
                {
                   $type=$_GET["typep"];
		}
                
                
                  if (isset($_SESSION['mail']))
                    {
                    $ses1=$_SESSION['mail'];
                        if($type=="maitrestage")
                            {
                  
                            $vco1="select * from personne as p, maitrestage as m, stage as s, encadre as e where p.IDPERSONNE=m.IDMAITRESTAGE AND m.IDMAITRESTAGE=e.IDMAITRESTAGE AND s.IDSTAGE=e.IDSTAGE AND MAILPERSONNE ='".$ses1."'";
                            $res1=$connexion->query($vco1);

                            while($donne =$res1->fetch(PDO::FETCH_ASSOC))
                                {
                                
                                $idSm=$donne['IDSTAGE'];
                
                $req_c="select * from personne as p, stage as s, eleve as e, classe as c where e.IDCLASSE=c.IDCLASSE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$idSm;
                $resu_cr=$connexion->query($req_c);
                if ($rep1=$resu_cr->fetch(PDO::FETCH_ASSOC))
                {

                    $ids=$rep1["IDSTAGE"];
                    //$id=$rep1["IDPERSONNE"];
                    $nomS=$rep1["NOMPERSONNE"];
                    $preS=$rep1["PRENOMPERSONNE"];
                    $sujetS=$rep1["SUJETSTAGE"];
                    $dateDS=$rep1["DATEDEBUT"];
                    $dateFS=$rep1["DATEFIN"];
                    $clas=$rep1["LIBELLECLASSE"];
                    
                    $anneeAct=date('Y');
                    $mois=date("m");
                    $Niveau=$rep1['ANNEE']-$anneeAct;
                    $Niveau2=0;
                    if((($Niveau==1)&&($mois<7))||(($Niveau==2)&&($mois>7)))
                    {
                        $Niveau2=1;
                    }else
                        {
                        $Niveau2=2;
                        }
                    echo '<table border="0" class="petitformdata"  align="center">
                        <tr>
                            <th>Nom : </th>
                            <th>Prénom : </th>
                            <th>Classe : </th>
                        </tr>
                        <tr>
                            <td>'.$nomS.'</td>
                            <td>'.$preS.'</td>
                            <td>'.$Niveau2.' '.$clas.'</td>
                        </tr>
                        <tr>
                            <th>Période début stage : </th>
                            <th>Période fin stage : </th>
                            <td>
                            <form action="compteRendu.php?id='.$ids.'" method="POST">
                                <input type="submit" name="btsuivi" value="Suivre" style="width:100px; height:35px;">
                            </form>
                            </td>
                        </tr>
                        <tr>
                            <td>'.mDate($dateDS).'</td>
                            <td>'.mDate($dateFS).'</td>
                        </tr>
                        <tr>
                            <th>Sujet : </th>
                        </tr>
                        <tr>
                            <td border="1" ><h4 >'.$sujetS.'</h4></td>                             
                        </tr>  

                    </table><br>';
                    
                    //<textarea id="sujet" style="color: slategray; " rows="" cols="50" reamdonly>'.$sujetS.'</textarea>
                    
                }
                                }
                            }else if($type=="eleve")
                            {
                                //à suivre...

                  
                            $vco1="select * from personne as p, eleve as el, stage as s where p.IDPERSONNE=el.IDELEVE AND el.IDELEVE=s.IDELEVE AND MAILPERSONNE ='".$ses1."'";
                            $res1=$connexion->query($vco1);

                            while($donne =$res1->fetch(PDO::FETCH_ASSOC))
                                {
                                
                                $idSm=$donne['IDSTAGE'];
                
                $req_c="select * from personne as p, stage as s, eleve as e, classe as c where e.IDCLASSE=c.IDCLASSE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$idSm;
                $resu_cr=$connexion->query($req_c);
                if ($rep1=$resu_cr->fetch(PDO::FETCH_ASSOC))
                {

                    $ids=$rep1["IDSTAGE"];
                    $sujetS=$rep1["SUJETSTAGE"];
                    $dateDS=$rep1["DATEDEBUT"];
                    $dateFS=$rep1["DATEFIN"];
                    $clas=$rep1["LIBELLECLASSE"];
                    
                    $anneeAct=date('Y');
                    $mois=date("m");
                    $Niveau=$rep1['ANNEE']-$anneeAct;
                    $Niveau2=0;
                    if((($Niveau==1)&&($mois<7))||(($Niveau==2)&&($mois>7)))
                    {
                        $Niveau2=1;
                    }else
                        {
                        $Niveau2=2;
                        }
                    echo '<table border="0" class="petitformdata"  align="center">
                        <tr>
                            <th>Classe : </th>
                            <th>Période début stage : </th>
                            <th>Période fin stage : </th>
                            <td>
                            <form action="compteRendu.php?id='.$ids.'" method="POST">
                                <input type="submit" name="btsuivi" value="Edition" style="width:100px; height:35px;">
                            </form>
                            </td>
                        </tr> 
                        <tr> 
                            <td>'.$Niveau2.' '.$clas.'</td>
                            <td>'.mDate($dateDS).'</td>
                            <td>'.mDate($dateFS).'</td>
                        </tr>
                        <tr>
                            <th>Sujet : </th>
                        </tr>
                        <tr>
                            <td border="1" ><h4 >'.$sujetS.'</h4></td>                             
                        </tr>  

                    </table><br>';
                    
                    //<textarea id="sujet" style="color: slategray; " rows="" cols="50" reamdonly>'.$sujetS.'</textarea>
                    
                }
                                }
                            }else if($type=="maitrestage")
                            {
                  
                            $vco1="select * from personne as p, maitrestage as m, stage as s, encadre as e where p.IDPERSONNE=m.IDMAITRESTAGE AND m.IDMAITRESTAGE=e.IDMAITRESTAGE AND s.IDSTAGE=e.IDSTAGE AND MAILPERSONNE ='".$ses1."'";
                            $res1=$connexion->query($vco1);

                            while($donne =$res1->fetch(PDO::FETCH_ASSOC))
                                {
                                
                                $idSm=$donne['IDSTAGE'];
                
               
             
                
                $req_c="select * from personne as p, stage as s, eleve as e, classe as c where e.IDCLASSE=c.IDCLASSE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$idSm;
                $resu_cr=$connexion->query($req_c);
                if ($rep1=$resu_cr->fetch(PDO::FETCH_ASSOC))
                {

                    $ids=$rep1["IDSTAGE"];
                    //$id=$rep1["IDPERSONNE"];
                    $nomS=$rep1["NOMPERSONNE"];
                    $preS=$rep1["PRENOMPERSONNE"];
                    $sujetS=$rep1["SUJETSTAGE"];
                    $dateDS=$rep1["DATEDEBUT"];
                    $dateFS=$rep1["DATEFIN"];
                    $clas=$rep1["LIBELLECLASSE"];
                    
                    $anneeAct=date('Y');
                    $mois=date("m");
                    $Niveau=$rep1['ANNEE']-$anneeAct;
                    $Niveau2=0;
                    if((($Niveau==1)&&($mois<7))||(($Niveau==2)&&($mois>7)))
                    {
                        $Niveau2=1;
                    }else
                        {
                        $Niveau2=2;
                        }
                    echo '<table border="0" class="petitformdata"  align="center">
                        <tr>
                            <th>Nom : </th>
                            <th>Prénom : </th>
                            <th>Classe : </th>
                        </tr>
                        <tr>
                            <td>'.$nomS.'</td>
                            <td>'.$preS.'</td>
                            <td>'.$Niveau2.' '.$clas.'</td>
                        </tr>
                        <tr>
                            <th>Période début stage : </th>
                            <th>Période fin stage : </th>
                            <td>
                            <form action="compteRendu.php?id='.$ids.'" method="POST">
                                <input type="submit" name="btsuivi" value="Suivre" style="width:100px; height:35px;">
                            </form>
                            </td>
                        </tr>
                        <tr>
                            <td>'.mDate($dateDS).'</td>
                            <td>'.mDate($dateFS).'</td>
                        </tr>
                        <tr>
                            <th>Sujet : </th>
                        </tr>
                        <tr>
                            <td border="1" ><h4 >'.$sujetS.'</h4></td>                             
                        </tr>  

                    </table><br>';
                    
                    //<textarea id="sujet" style="color: slategray; " rows="" cols="50" reamdonly>'.$sujetS.'</textarea>
                    
                }
                                }
                            }else if($type=="admin")
                            {
                  
                            $vco1="select * from personne where MAILPERSONNE ='".$ses1."'";
                            $res1=$connexion->query($vco1);

                            if($donne =$res1->fetch(PDO::FETCH_ASSOC))
                                {
                               
                                
                $req_c="select * from personne as p, stage as s, eleve as e, classe as c where e.IDCLASSE=c.IDCLASSE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE";
                $resu_cr=$connexion->query($req_c);
                if ($rep1=$resu_cr->fetch(PDO::FETCH_ASSOC))
                {

                    $ids=$rep1["IDSTAGE"];
                    //$id=$rep1["IDPERSONNE"];
                    $nomS=$rep1["NOMPERSONNE"];
                    $preS=$rep1["PRENOMPERSONNE"];
                    $sujetS=$rep1["SUJETSTAGE"];
                    $dateDS=$rep1["DATEDEBUT"];
                    $dateFS=$rep1["DATEFIN"];
                    $clas=$rep1["LIBELLECLASSE"];
                    
                    $anneeAct=date('Y');
                    $mois=date("m");
                    $Niveau=$rep1['ANNEE']-$anneeAct;
                    $Niveau2=0;
                    if((($Niveau==1)&&($mois<7))||(($Niveau==2)&&($mois>7)))
                    {
                        $Niveau2=1;
                    }else
                        {
                        $Niveau2=2;
                        }
                    echo '<table border="0" class="petitformdata"  align="center">
                        <tr>
                            <th>Nom : </th>
                            <th>Prénom : </th>
                            <th>Classe : </th>
                        </tr>
                        <tr>
                            <td>'.$nomS.'</td>
                            <td>'.$preS.'</td>
                            <td>'.$Niveau2.' '.$clas.'</td>
                        </tr>
                        <tr>
                            <th>Période début stage : </th>
                            <th>Période fin stage : </th>
                            <td>
                            <form action="compteRendu.php?id='.$ids.'" method="POST">
                                <input type="submit" name="btsuivi" value="Suivre" style="width:100px; height:35px;">
                            </form>
                            </td>
                        </tr>
                        <tr>
                            <td>'.mDate($dateDS).'</td>
                            <td>'.mDate($dateFS).'</td>
                        </tr>
                        <tr>
                            <th>Sujet : </th>
                        </tr>
                        <tr>
                            <td border="1" ><h4 >'.$sujetS.'</h4></td>                             
                        </tr>  

                    </table><br>';
                    
                    //<textarea id="sujet" style="color: slategray; " rows="" cols="50" reamdonly>'.$sujetS.'</textarea>
                    
                }
                                }
                            }
                    }
                    
            
                ?>
                 </div><br>
                  <FORM style="float:left; margin-top: -20px; background-color: orange; "> <INPUT TYPE="button" VALUE="Retour" onClick="history.back()"> </FORM> 
                
            <?php
                          /* }else if ($statut1 == "professeur")
			   {?>
            
            
            
            
             <?php
                           }else if ($statut1 == "eleve")
			   {?>
            
            
            
            
             <?php
                           }else if ($statut1 == "maitredestage")
			   {*?>
            
            
            
            <?php }*/require_once 'pied.php';?>
        </div>
        </div>
    </body>
</html>